home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / FALCON / CPX / GENERAL.TC / STATUS.C2 < prev    next >
Encoding:
Text File  |  2001-02-10  |  5.5 KB  |  272 lines

  1. /* STATUS.C
  2.  *==========================================================================
  3.  * DATE:    February 2, 1990
  4.  * DESCRIPTION:
  5.  */
  6.  
  7.  
  8.  
  9.  
  10. /* INCLUDE FILES
  11.  *==========================================================================
  12.  */
  13. #include <sys\gemskel.h>
  14. #include <tos.h>
  15. #include <string.h>
  16. #include <stdlib.h>
  17.  
  18. #include "general.h"
  19. #include "super.h"
  20.  
  21.  
  22.  
  23. /* PROTOTYPES
  24.  *==========================================================================
  25.  */
  26. void do_os( void );
  27. void do_status( void );
  28. void clear_status( void );
  29. void do_memory( int Total_object, int Free_object );
  30. void wait_button( int flag );
  31.  
  32.  
  33.  
  34. /* DEFINES
  35.  *==========================================================================
  36.  */
  37. #define UP     0                /* wait button up   */
  38. #define DOWN     1                /* wait button down */
  39. #define STRAM    0
  40.  
  41. #define VERTICAL    0
  42. #define HORIZONTAL    1
  43. #define SCROLL_OFFSET    8
  44.  
  45.  
  46.  
  47. /* EXTERNALS
  48.  *==========================================================================
  49.  */
  50. extern long rs_trindex[];
  51.  
  52.  
  53. /* GLOBALS
  54.  *==========================================================================
  55.  */
  56. int  errno;                /* errno declaration        */
  57.  
  58. int  max_stat;                /* max and min y value of status*/
  59. int  min_stat;                /* Note, these are y offsets... */
  60. char tosdate[10];            /* TOS VERSON DATE        */
  61. char tosvers[10];            /* TOS VERSION NUMBER        */
  62.  
  63. char total[8];                /* ST RAM total available       */
  64. char tfree[8];                /* ST RAM free...        */
  65.  
  66. int blit_inc;                /* incrementer for scrolling of */
  67.                     /* the status box...        */
  68.                     /* see sl_y for implementation. */
  69. int stat_value;                /* y variable of status slider  */
  70.                     /* Note: it is an offset    */
  71.                     /* off of the current y value   */
  72.  
  73. /* FUNCTIONS
  74.  *==========================================================================
  75.  */
  76.  
  77.  
  78. /* do_os()
  79.  *==========================================================================
  80.  */
  81. void
  82. do_os( void )
  83. {
  84.   OBJECT *ad_partz    = (OBJECT *)rs_trindex[PARTZ];
  85.   OBJECT *tree;
  86.   char *version;
  87.   char *osdate;
  88.   int j;
  89.   SYSHDR *osheader;
  90.   char  num;
  91.   
  92.   Enter_Super();
  93.   osheader = *((SYSHDR **)0x4f2L);
  94.   Exit_Super();
  95.   
  96.   osheader = osheader->os_base;
  97.   version  = (char *)&osheader->os_version;
  98.   osdate   = (char *)&osheader->os_gendat;
  99.   
  100.   for(j = 0;j<=3;j += 2)
  101.   {
  102.     num = *version++;
  103.     tosvers[j] = ((num & 0xf0) >> 4) + '0';
  104.     tosvers[j+1] = (num & 0x0f) + '0';
  105.   }
  106.   
  107.   for(j = 0;j<=7;j += 2)
  108.   {
  109.      num = *osdate++;
  110.      tosdate[j] = ((num & 0xf0) >> 4) + '0';
  111.      tosdate[j+1] =  (num & 0x0f) +  '0';
  112.   }
  113.   
  114.   ActiveTree( ad_partz );
  115.   
  116.   TedText( OSDATE ) = &tosdate[0];
  117.   TedText( VERSION ) = &tosvers[0];
  118. }
  119.  
  120.  
  121.  
  122.  
  123. /* do_status()
  124.  *==========================================================================
  125.  */
  126. void
  127. do_status( void )
  128. {
  129.   OBJECT *ad_tree  = (OBJECT *)rs_trindex[GENERAL];
  130.   OBJECT *ad_partz = (OBJECT *)rs_trindex[PARTZ];
  131.   OBJECT *tree;
  132.   int x,y;
  133.   int button;
  134.   int done = FALSE;
  135.  
  136.   ActiveTree( ad_tree );
  137.   x = ObX( ROOT );
  138.   y = ObY( ROOT );
  139.   Deselect( STATUS );
  140.     
  141.   ActiveTree( ad_partz );
  142.   ObX( ROOT ) = x;
  143.   ObY( ROOT ) = y;
  144.   
  145.   do_os();
  146.   do_memory( STTOTAL, STFREE );
  147.  
  148.   Objc_draw( tree, ROOT, MAX_DEPTH, NULL );
  149.   do
  150.   {
  151.      button = form_do( tree, 0 );
  152.      
  153.      switch( button )
  154.      {
  155.            case STATOK:   done = TRUE;
  156.                     SetNormal( button );    
  157.                       clear_status();
  158.                       break;
  159.                    
  160.           default:     done = TRUE;
  161.                    clear_status();
  162.                        break;
  163.      }
  164.   }while( !done ); 
  165. }
  166.  
  167.  
  168.  
  169. /* clear_status()
  170.  *==========================================================================
  171.  */
  172. void
  173. clear_status( void )
  174. {
  175.   OBJECT *ad_tree  = (OBJECT *)rs_trindex[GENERAL];
  176.   OBJECT *ad_partz = (OBJECT *)rs_trindex[PARTZ];
  177.   OBJECT *tree;
  178.  
  179.   ActiveTree( ad_partz );
  180.   Deselect( STATOK );
  181.   
  182.   ActiveTree( ad_tree );
  183.   Objc_draw( ad_tree, GENERAL, MAX_DEPTH, NULL );
  184.   wait_button( UP );
  185. }
  186.  
  187.  
  188.  
  189. /* do_memory()
  190.  *==========================================================================
  191.  */
  192. void
  193. do_memory( int Total_object, int Free_object )
  194. {
  195.   OBJECT *ad_partz = (OBJECT *)rs_trindex[PARTZ];
  196.   OBJECT *tree;
  197.  
  198.   long totalnum = 0L;
  199.   long freenum  = 0L;
  200.   long tempnum  = 0L;
  201.   
  202.   long *mptr;
  203.   long *head;
  204.   long *tptr;
  205.   long *xptr;
  206.   
  207.   char *xtotal;
  208.   char *xfree;
  209.  
  210.   Enter_Super();
  211.   totalnum = *(long *)0x42EL;
  212.   Exit_Super();
  213.  
  214.   xtotal = (char *)&total;
  215.   xfree  = (char *)&tfree;
  216.   
  217.   ltoa( totalnum, xtotal, 10 );
  218.  
  219.   head = mptr = tptr = 0L;
  220.   tempnum = ( long )Malloc( -1L );
  221.   while( tempnum > 4L )
  222.   {
  223.      if( !head )
  224.      {
  225.         head  = mptr = Malloc( tempnum );
  226.         *head = 0L;
  227.      }
  228.      else
  229.      {
  230.         tptr  = Malloc( tempnum );
  231.         *tptr = 0L;
  232.         *mptr = ( long )tptr;
  233.         mptr  = tptr;
  234.      }
  235.      freenum += tempnum;
  236.      tempnum = ( long )Malloc( -1L );       
  237.   }
  238.   
  239.  
  240.   if( head )
  241.   {  
  242.     tptr = 0L;
  243.     while( *head )
  244.     {
  245.        mptr = (long *)*head;
  246.        xptr = head;
  247.        while( mptr )
  248.        {
  249.             tptr = mptr;
  250.             mptr = ( long *)*mptr;
  251.             if( mptr )
  252.                 xptr = tptr;
  253.        }
  254.        if( tptr )
  255.        {
  256.           Mfree( tptr );
  257.           tptr  = ( long *)0L;
  258.           *xptr = 0L;
  259.        }
  260.     }
  261.     Mfree( head );
  262.   }
  263.   
  264.   ltoa( freenum, xfree, 10 );
  265.   
  266.   ActiveTree( ad_partz );
  267.   ObString( Total_object ) = xtotal;  
  268.   ObString( Free_object )  = xfree;
  269. }
  270.  
  271.  
  272.